//
//@File    :	6.13_cinfish.cpp
//@Time    :	2021/08/07 20:28:57
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	non-numeric input terminaters loop
//

#include <iostream>
const int Max = 5;
int main()
{
    using namespace std;
    double fish[Max];
    cout<<"Please enter the weights of your fish.\n";
    cout<<"You may enter up to "<<Max
        <<" fish <q to terminate>.\n";
    cout<<"fish #1: ";
    int i = 0;
    while(i<Max && cin>>fish[i])
    {
        if (++i<Max)
        {
            cout<<"fish #"<<i+1<<": ";
        }
    }
        double total = 0.0;
        for (int j = 0; j < i; j++)
        {
            total +=fish[j];
        }
        if (i==0)
        {
            cout<<"No fish\n";
        }
        else
        {
            cout<<total/i<<" = average weight of "
                <<i<<" fissh\n";
        }
        cout<<"Done.\n";
    system("pause");
    return 0;
}